#include<cstdio>
#include<cstring>
const int MAX = 2100000000;
int b[101][101],num[101],p[101][101],flag[32768];
int t;
int main()
{
	freopen("test.in","r",stdin);
	scanf("%d",&t);
	while(t--)
	{
		int n,l=MAX,r=MAX;
		scanf("%d",&n);
		memset(flag,false,sizeof(flag));
		for(int i=1;i<=n;i++)
		{
			int max=-1*MAX,min=MAX;
			scanf("%d",&num[i]);
			for(int j=1;j<=num[i];j++)
			{
				scanf("%d%d",&b[i][j],&p[i][j]);
				flag[b[i][j]]=true;
				max=max>b[i][j]?max:b[i][j];
				min=min<b[i][j]?min:b[i][j];
			}
			l=l<min?l:min;
			r=r<max?r:max;
		}
		double ans=0;
		for(int i=l;i<=r;i++)
			if(flag[i])
			{
				int sump=0;
				for(int j=1;j<=n;j++)
				{
					int minp=MAX;
					for(int k=1;k<=num[j];k++)
						if(b[j][k]>=i)minp=minp<p[j][k]?minp:p[j][k];
					sump+=minp;
				}
				ans=ans>(double)i/sump?ans:(double)i/sump;
			}
		printf("%0.3lf\n",ans);
	}
	return 0;
}

